LLMs, RAG, and the Shattered Mirror

Large Language Models, Training Data, and the Context Window

Assembling the viewAssembling the view

Large Language Models (LLMs) use statistical weights generated against an initial (often vast) set of training data. This provides them with a baseline of broad, holistic, statistical patterns. LLMs can then process input tokens (you can think of them as words) into a “context window” that holds the tokens that an LLM currently “remembers” in its short-term memory.

So, the training data for a given model exists as a baseline, while the context window holds the current conversation (if any) and any new data processed by the LLM at runtime. Each time an LLM is invoked the old context window is gone, and tokens need to be processed again.

In that sense, an LLM is like a person who has lost the facility to shift memories from short-term to long-term memory and continually “wakes up” starting from the moment when training ended.

LLMs have well-known problems with inaccuracy and confabulation. Since they work statistically, they cannot tell the difference between an accurate answer and a statistically probable (typically reasonable sounding) answer.

Retrieval Augmented Generation (RAG)

Large Language Models (LLMs) can use the Retrieval Augmented Generation (RAG) technique to generate more accurate answers. RAG primarily helps in two areas:

  • Providing answers based on data outside the LLM’s training data
  • Providing more factual answers with less confabulation

A RAG approach provides the LLM access to a search engine (either an internet search engine or a database of pre-ingested content) of data that the LLM can use to provide more accurate results, or to become aware of data outside its training data.

Training Data and the Context Window

However, RAG techniques still work within the current limitations of LLMs. As mentioned above, LLMs have the statistical weights of their training data. This gives an LLM holistic statistical knowledge of the world as represented by the training data. This knowledge (in the form of statistical weights) is always inherently available to an LLM.

The other kind of knowledge LLMs have is weights held in the current context window. One can think about the context window as session memory or short-term memory. The context window’s limited size means a longer conversation or document may exceed what the context window can hold, causing the LLM to “forget” aspects of the current interaction or document.

Anything in the context window comes from processing tokens of a larger input (such as the conversation or a text document). Tokens can be thought of as the small, word-like chunks that textual LLMs process. Processing tokens takes time and processing power.

So, the RAG approach triggers a search of either a pre-ingested database of document fragments or an internet search. The LLM processes the search results so an answer can be given based on data loaded into the context window.

You’ll note, however, that the limits of the context window and processing time remain. The LLM has to process the search results before it can use them. This means either there is a long delay (with a chance of filling up the context window), or only shorter text fragments get processed.

It’s almost like the more complete view of post-training data has been shattered into fragments, much like a broken mirror. The LLM can select a few of the most promising pieces for processing, but only a handful can be “picked up” at a time.

This creates a stark boundary between the more global/holistic/statistical knowledge of training data, and only piecemeal access to what is available through the RAG approach. This works reasonably well for spot-checking accuracy, but poorly for getting a broad-based view of newer data.

A few examples

Blog posts

Suppose, for example, a blogger has made all their blog posts available to an LLM using RAG. The LLM could easily answer questions like “Can you summarize places where I mentioned the subway?” as long as there weren’t many occurrences. However, if you asked the LLM “How would you describe my general style?” it could only process a few examples in a reasonable period of time, and would lack a holistic view of your blog posts.

A code base

Alternatively, a programmer working on a large code base might make the code available to an LLM using a RAG approach. The LLM can then “look” at the most related fragments of files (or entire smaller files) when answering questions.

However, if you wanted the LLM to follow the general programming style of your code base, have insights about the broader patterns, or scan the entire code base for code that doesn’t follow the coding standards, an LLM cannot do so in a timely fashion.

Company documents

Similarly, if an IT person created a RAG database of company documents, an LLM could easily find related documents and summarize snippets of those documents, but would be unable to accurately assess holistic patterns or trends, and would take a long time to summarize lengthy documents that might, even then, exceed the context window of the LLM.

LLMs aren’t magic

So, LLMs (even using RAG) are not magic. They are at the mercy of their training data and the processing time to load new data into their context window. When going beyond their training data, they can only consider a handful of pieces of the shattered mirror. They straddle a holistic and statistical world of their vast training data and the constrained time-bound and memory-bound world of their context window.


Date
March 23, 2025